<?php

class BenefitMapper extends BaseMapper{
	
	function getBenefits() {			
		$this->keys = array("name","description","company", "endDateTime", "id", "latitude", "longitude");
		$this->moreMapping = array("addDistance","replaceEnter", "fullAddress", "map", "category");
    }      
    	  
	function replaceEnter($obj, &$attributes){
    	$attributes["description"] = str_replace("\r\n","\n", $attributes["description"]); 
    }
    
    function addDistance($obj, &$attributes){
    	if(isset($obj->distance)){
    		$attributes["distance"] = $obj->distance;
    	}
    }
    
	function fullAddress($obj, &$attributes){    	
    	$attributes["fullAdress"] = $obj->getFullAddress();	
    }
    
	function map($obj, &$attributes){    	
    	$attributes["map"] = buildMapUrl($obj->attributes->latitude, $obj->attributes->longitude);	
    }
    
	function category($obj, &$attributes){
		$category = new Category($obj->attributes->idCategory);    	
    	$attributes["category"] = $category->attributes->name;	
    }

}

?>